// pages/entering/entering.js
var app = getApp();
var com = require('../../common.js');
var lson = require('../../utils/list.js')
Page({
  data: {
    type: 1,
    jy_zd: false,
    yy_zd: false,
    id: '',
    string: {},
    name:''
  },
  onLoad: function(options) {
    var _this = this

    _this.setData({
      id: options.id,
      listinfo: lson.listYl,
      name:options.name
    })
    console.log(lson.listYl, _this.data.listinfo)
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  onShareAppMessage: function() {},
  affirm: function(e) {
    var _this = this,
      data = e.detail.value
    data.user = _this.data.id
    data.jy_zd = _this.data.jy_zd
    data.yy_zd = _this.data.yy_zd
    com.link(app.link.optomtetrys, data, function(res) {
      console.log(res, _this.data);
      if (res.data.state) {
        wx.showModal({
          title: '温馨提示',
          content: '添加验光数据成功',
          success(res) {
            if (res.confirm) {
              wx.navigateBack({
                delta: 1
              })
            }
          }
        })
      } else {
        wx.showModal({
          title: '温馨提示',
          content: res.data.message,
        })
      }
    })
  },
  ontype(e) {
    var _this = this
    _this.setData({
      type: e.currentTarget.id,
    })
  },
  checkbox(e) {
    console.log(e)
    var _this = this,
      id = _this.data.type
    if (id == 1) {
      _this.setData({
        jy_zd: e.currentTarget.id == 1? true : false
      })
    } else {
      _this.setData({
        yy_zd: e.currentTarget.id == 1 ? true : false
      })
    }
  },
  onPickerMove(e) {
    var _this = this,
      list = _this.data.listinfo,
      string = _this.data.string,
      id = e.currentTarget.id,
      name = e.currentTarget.dataset.name
    if (id == 1) {
      string.jy_l_qj = list.qj[e.detail.value]
    }
    if (id == 2) {
      string.jy_r_qj = list.qj[e.detail.value]
    }
    if (id == 3) {
      string.jy_l_zj = list.zj[e.detail.value]
    }
    if (id == 4) {
      string.jy_r_zj = list.zj[e.detail.value]
    }
    if (id == 5) {
      string.jy_l_zx = list.zw[e.detail.value]
    }
    if (id == 6) {
      string.jy_r_zx = list.zw[e.detail.value]
    }
    if (id == 7) {
      string.jy_l_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 8) {
      string.jy_r_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 9) {
      string.jy_l_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 10) {
      string.jy_r_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 11) {
      string.jy_l_tj = list.tj[e.detail.value]
    }
    if (id == 12) {
      string.jy_r_tj = list.tj[e.detail.value]
    }
    if (id == 13) {
      string.jy_l_xjg = list.add[e.detail.value]
    }
    if (id == 14) {
      string.jy_r_xjg = list.add[e.detail.value]
    }
    // ---------------------------------------------
    if (id == 15) {
      string.yy_l_qj = list.qj[e.detail.value]
    }
    if (id == 16) {
      string.yy_r_qj = list.qj[e.detail.value]
    }
    if (id == 17) {
      string.yy_l_zj = list.zj[e.detail.value]
    }
    if (id == 18) {
      string.yy_r_zj = list.zj[e.detail.value]
    }
    if (id == 19) {
      string.yy_l_zx = list.zw[e.detail.value]
    }
    if (id == 20) {
      string.yy_r_zx = list.zw[e.detail.value]
    }
    if (id == 21) {
      string.yy_l_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 22) {
      string.yy_r_dyjzsl = list.dyjz[e.detail.value]
    }
    if (id == 23) {
      string.yy_l_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 24) {
      string.yy_r_syjzsl = list.dyjz[e.detail.value]
    }
    if (id == 25) {
      string.yy_l_tj = list.tj[e.detail.value]
    }
    if (id == 26) {
      string.yy_r_tj = list.tj[e.detail.value]
    }
    if (id == 27) {
      string.yy_l_xjg = list.add[e.detail.value]
    }
    if (id == 28) {
      string.yy_r_xjg = list.add[e.detail.value]
    }
    _this.setData({
      string: string
    })

  }
})